package com.aaa.member.service.impl;

import com.aaa.common.util.Result;
import com.aaa.member.dao.CommonAddressDao;
import com.aaa.member.entity.CommonAddress;
import com.aaa.member.service.CommonAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 常用地址
 * (CommonAddress)表服务实现类
 *
 * @author makejava
 * @since 2020-11-27 14:58:30
 */
@Service("commonAddressService")
public class CommonAddressServiceImpl implements CommonAddressService {
    @Resource
    private CommonAddressDao commonAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CommonAddress queryById(Integer id) {
        return this.commonAddressDao.queryById(id);
    }

    @Override
    public List<CommonAddress> queryAllAddress(CommonAddress commonAddress) {
        return commonAddressDao.queryAll(commonAddress);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CommonAddress> queryAllByLimit(int offset, int limit) {
        return this.commonAddressDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param commonAddress 实例对象
     * @return 实例对象
     */
    @Override
    public CommonAddress insert(CommonAddress commonAddress) {
        this.commonAddressDao.insert(commonAddress);
        return commonAddress;
    }

    /**
     * 修改数据
     *
     * @param commonAddress 实例对象
     * @return 实例对象
     */
    @Override
    public CommonAddress update(CommonAddress commonAddress) {
        this.commonAddressDao.update(commonAddress);
        return this.queryById(commonAddress.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.commonAddressDao.deleteById(id) > 0;
    }
}